package androidgames.networkgames.screens;

import java.util.ArrayList;
import java.util.List;
import androidgames.networkgames.screens.components.DrawableComponent;

import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Input.*;
import com.badlogic.androidgames.framework.Graphics;
import com.badlogic.androidgames.framework.Pixmap;
import com.badlogic.androidgames.framework.Screen;

public abstract class BaseScreen extends Screen {
	
	Pixmap background;
	public Graphics g;
	List<DrawableComponent> componentList;
	
	public BaseScreen(Game game) {
		super(game);
		// TODO Auto-generated constructor stub
		background = null;
		componentList = new ArrayList<DrawableComponent>();
		g = game.getGraphics();
	}
	
	@Override
	public void update(float deltaTime)
	{
		List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
        for(int i = 0; i < touchEvents.size(); i++)
        {
        	for(int j = 0; j < componentList.size(); j++)
            {
            	boolean bIsProcessed = componentList.get(j).update(deltaTime, touchEvents.get(i));
            	if(bIsProcessed)
            		continue;
            }
        }
        
	}
	
	@Override
	public void present(float deltaTime)
	{
		g.drawPixmap(background, 0, 0);
		for(int j = 0; j < componentList.size(); j++)
        {
        	componentList.get(j).present(deltaTime, g);
        }
	}
	
	public abstract void addComponent(DrawableComponent component);
}
